﻿using System.Web.UI;
using Cvk.News;
using System.Web.UI.HtmlControls;
using System.Text.RegularExpressions;
public class Utility
{
    public Utility() { }    
    public static string strConnect
    {
        get { return cvk.Connection.GetConnect("cvkConnectionString"); }
    }
    public static void LoadHeader(Page _page, int idCulture, int idType, string strConnect)
    {
        try
        {
            VG_NewsType info = new VG_NewsType();

            info = NewsBll.claNewsTypeDetail.GetInfo(idCulture, idType, strConnect);

            HtmlHead head_tag = (HtmlHead)_page.Header;
            head_tag.Title = info.SeoTitle;

            head_tag.Controls.Add(new LiteralControl("\r\n"));

            HtmlMeta meta_tag = new HtmlMeta();
            meta_tag.Name = "Description";
            meta_tag.Content = info.SeoDescription;
            head_tag.Controls.Add(meta_tag);
            head_tag.Controls.Add(new LiteralControl("\r\n"));

            meta_tag = new HtmlMeta();
            meta_tag.Name = "Keywords";
            meta_tag.Content = info.SeoKeyword;
            head_tag.Controls.Add(meta_tag);
            head_tag.Controls.Add(new LiteralControl("\r\n"));
        }
        catch { }
    }
    public static void LoadHeaderNewsDetail(Page _page, int idCulture, int idNews, string strConnect)
    {
        try
        {
            Cvk_NewsDetail info = new Cvk_NewsDetail();

            info = NewsBll.claNewsDetail.GetInfo(idCulture, idNews, strConnect);
            HtmlHead head_tag = (HtmlHead)_page.Header;
            head_tag.Controls.Add(new LiteralControl("\r\n"));
            //head_tag.Title = info.SeoTitle;
            //head_tag.Controls.Add(new LiteralControl("\r\n"));

            HtmlMeta meta_tag = new HtmlMeta();
            meta_tag.Name = "description";
            meta_tag.Content = info.SeoDescription;
            head_tag.Controls.Add(new LiteralControl("\r\n"));
            head_tag.Controls.Add(meta_tag);
            head_tag.Controls.Add(new LiteralControl("\r\n"));

            meta_tag = new HtmlMeta();
            meta_tag.Name = "keywords";
            meta_tag.Content = info.SeoKeyword;
            head_tag.Controls.Add(meta_tag);
            head_tag.Controls.Add(new LiteralControl("\r\n"));

            HtmlTitle title_tag = new HtmlTitle();
            title_tag.Text = info.SeoTitle;
            head_tag.Controls.Add(title_tag);
            head_tag.Controls.Add(new LiteralControl("\r\n"));
        }
        catch { }
    }
    public static string RemoveHtml(string str)
    {
        try
        {
            return Regex.Replace(str, @"<(.|\n)*?>", string.Empty);
        }
        catch
        {
            return "";
        }
    }
}

